/*
 * DevicesLed.h
 *
 *      Author: Honrun
 */

#ifndef BSP_DEVICESLED_H_
#define BSP_DEVICESLED_H_


/* 周期时间（ms） */
#define LED_PERIODIC_TIME   100
#define LED_FLASH_SLOW_TIME 1000
#define LED_FLASH_FAST_TIME 500


#define LED_RED    0x01
#define LED_GREEN  0x02
#define LED_BLUE   0x04
#define LED_YELLOW 0x08
#define LED_WHITE  0x10
#define LED_BAG    0x20
#define LED_EXIST  0x40
#define LED_ALL    0xFF


typedef enum {
    LED_IDLE                    = 0,
    LED_DISABLE,                /* 关闭 */
    LED_ENABLE,                 /* 常亮 */
    LED_FLASH_SLOW_CIRCULAR,    /* 循环慢闪（0.5Hz） */
    LED_FLASH_SLOW_ENABLE_CNT,  /* 慢闪N次后LED常亮 */
    LED_FLASH_SLOW_DISABLE_CNT, /* 慢闪N次后LED关闭 */
    LED_FLASH_FAST_CIRCULAR,    /* 循环快闪（1Hz） */
    LED_FLASH_FAST_ENABLE_CNT,  /* 快闪N次后LED常亮 */
    LED_FLASH_FAST_DISABLE_CNT, /* 快闪N次后LED关闭 */
    LED_BREATHE,                /* 呼吸 */
    LED_DUTY,                   /* 固定占空比 */
} LedStateEnum;


typedef struct{
    uint8_t state;          /* 状态 */
    uint16_t channel;       /* 通道 */
    int8_t flashCnt;        /* 闪烁次数 */
}LedType;


typedef struct{
    LedType white;
    LedType blue;
}LedInfoType;




void vLedInit(void);
void vLedOpen(uint16_t ucNumber);
void vLedClose(uint16_t ucNumber);
void vLedRevesal(uint16_t ucNumber);
void vLedDuty(uint16_t usChannel, float fDuty);

void vLedSetStatus(uint16_t usChannel, LedStateEnum enumStatus, uint8_t ucFlashCnt_or_Duty);
void vLedMachine(void);

LedInfoType *ptypeLedGetInfo(void);


#define LED_OPEN()      vLedOpen(LED_ALL)
#define LED_CLOSE()     vLedClose(LED_ALL)
#define LED_REVESAL()   vLedRevesal(LED_ALL)



#endif /* BSP_DEVICESLED_H_ */
